package com.example.kiratest.notify.Test;

import com.alibaba.fastjson.JSON;
import com.example.kiratest.notify.DingtalkNotifier;
import com.example.kiratest.notify.Enum.MsgTypeEnum;
import com.example.kiratest.notify.POJO.CardRequest;
import com.example.kiratest.notify.POJO.DingtalkTableItem;

import java.util.UUID;

/**
 * 直接将定义好的卡片模板发送到群聊,不需要传我们的数据
 */
public class KiraEasyMain {
    public static void main(String[] args) {


        //卡片请求对象
        CardRequest pbNotifierMsg = pbNotifierMsg();

        //如果是特定的卡片我们可以按照特定的格式往里面发放数据
//        pbNotifierMsg.getCardData().getCardParamMap().getTableBean().setData(XXX);
        DingtalkTableItem tableBean = pbNotifierMsg.getCardData().getCardParamMap().getTableBean();

        pbNotifierMsg.getCardData().getCardParamMap().setTable(JSON.toJSONString(tableBean));
        //这个是我的群聊Id
        //详细看枚举类，我的枚举类是这样的      NOTIFY2(1, "通知类消息","dtv1.card//IM_GROUP.cid6Ks/gaDvofWDO3rp4XyA1A==")
        pbNotifierMsg.setOpenSpaceId(MsgTypeEnum.NOTIFY2.getOpenSpaceId());
        //这个是我的模板Id
        pbNotifierMsg.setCardTemplateId("28553af7-0e99-4e94-b540-56027baddf28.schema");
        pbNotifierMsg.setOutTrackId(UUID.randomUUID().toString());

        //将卡片对象转成String
        String jsonString = JSON.toJSONString(pbNotifierMsg);

        DingtalkNotifier dingtalkNotifier = new DingtalkNotifier();

        //发起请求
        dingtalkNotifier.notify(jsonString, null);
    }

    public static CardRequest pbNotifierMsg() {
        return new CardRequest("offer监控通知", null);
    }


}
